module CommentsHelper
  def comment_body comment
    comment_replace_newlines comment
  end
    
  def comment_replace_newlines comment
    (h comment.body.strip).gsub(/\n{2,}/,"<br/><br/>").gsub(/\n/,"<br/>")
  end
  
  def commentable_link commentable, display = " > "
    case commentable
      when Photo
        link_to( 
          display, 
          target_link(commentable),
          :rel    => "lightbox",
          :pid    => commentable.id,
          :title  => h(commentable.caption.to_s)
        )
      else
        link_to( 
          display, 
          target_link(commentable) )
    end
  end
end
